<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: base   g.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1316139452.16" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1316139452.16" />

    <script type="text/javascript" src="assets/api-js?stamp=1316139452.16"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1316139452.16"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="g-javascript-lib">g-javascript-lib</a></h1>
        <h3>base&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html" title="g-javascript-lib">g-javascript-lib</a> 
            &gt; <a href="./module_base.html" title="base">base</a>
                
                 &gt; g.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * A Javascript Library to extend standard HTML DOM interface.</span>
<span class="cm"> * @module base</span>
<span class="cm"> * @namespace</span>
<span class="cm"> */</span>

<span class="kd">var</span> <span class="nx">G</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">console</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;undefined&quot;</span><span class="p">)</span> <span class="p">{</span>
	<span class="nx">console</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="p">};</span>
	<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){};</span>
	<span class="nx">console</span><span class="p">.</span><span class="nx">err</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){};</span>
<span class="p">}</span>
<span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
	<span class="kd">var</span> <span class="nx">__Document</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">__DomElements</span> <span class="o">=</span> <span class="p">{};</span> 
	<span class="kd">var</span> <span class="nx">__UUID</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

	<span class="cm">/**</span>
<span class="cm">	 * &lt;p&gt;The global namespace.&lt;/p&gt;</span>
<span class="cm">	 * &lt;p&gt;It&#39;s also a factory to create an instance of G.DOM.Element.&lt;/p&gt;</span>
<span class="cm">	 * &lt;p&gt;Use following code to create an Instance of DomElement:&lt;br/&gt;</span>
<span class="cm">	 * var obj = G(selector)&lt;br/&gt;</span>
<span class="cm">	 * There 3 kind of selector supported:</span>
<span class="cm">	 *	string: as the Id of the element&lt;br/&gt;</span>
<span class="cm">	 *	document: the document of DOM.&lt;br/&gt;</span>
<span class="cm">	 *	DOM element: the Dom element. An id will be assigned to the </span>
<span class="cm">	 *	element if it has not a id.</span>
<span class="cm">	 * &lt;/p&gt;</span>
<span class="cm">	 * @class G</span>
<span class="cm">	 * @param selector {string} the id of the dom element</span>
<span class="cm">	 * @param selector {document} </span>
<span class="cm">	 * @param selector {dom element} </span>
<span class="cm">	 */</span>
	<span class="nx">G</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">selector</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">selector</span> <span class="o">==</span> <span class="nb">document</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">__Document</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">__Document</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">(</span><span class="nb">document</span><span class="p">);</span>
			<span class="p">}</span>
			<span class="k">return</span> <span class="nx">__Document</span><span class="p">;</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">selector</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">selector</span> <span class="k">in</span> <span class="nx">__DomElements</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">return</span> <span class="nx">__DomElements</span><span class="p">[</span><span class="nx">selector</span><span class="p">];</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">selector</span><span class="p">);</span>
				<span class="k">if</span> <span class="p">(</span><span class="nx">em</span><span class="p">)</span> <span class="p">{</span>
					<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>
					<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">em</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span> <span class="o">!=</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
						<span class="nx">em</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">G</span><span class="p">.</span><span class="nx">get_uuid</span><span class="p">(</span><span class="s1">&#39;dom_&#39;</span><span class="p">);</span>
					<span class="p">}</span>
					<span class="nx">__DomElements</span><span class="p">[</span><span class="nx">em</span><span class="p">.</span><span class="nx">id</span><span class="p">]</span> <span class="o">=</span> <span class="nx">g</span><span class="p">;</span>
					<span class="k">return</span> <span class="nx">g</span><span class="p">;</span>
				<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
					<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Can&#39;t find the DOM Element with id=&quot;</span> <span class="o">+</span> <span class="nx">selector</span><span class="p">);</span>
				<span class="p">}</span>
			<span class="p">}</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">return</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">(</span><span class="nx">selector</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Create a new Namespace with given name for G</span>
<span class="cm">	 * @static</span>
<span class="cm">	 * @method Namespace</span>
<span class="cm">	 * @param name {string}</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Namespace</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
		<span class="nx">G</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">G</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">||</span> <span class="p">{};</span>
	<span class="p">}</span>

	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span> <span class="o">=</span> <span class="p">{};</span>


	<span class="cm">/**</span>
<span class="cm">	 * the uuid is a number keep increasing on every time the get_uuid was called.</span>
<span class="cm">	 * @static</span>
<span class="cm">	 * @method get_uuid</span>
<span class="cm">	 * @param prefix {string}</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">get_uuid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">prefix</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="nx">__UUID</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">;</span>
		<span class="k">return</span> <span class="nx">prefix</span> <span class="o">+</span> <span class="nx">__UUID</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * This function define a new Class in namespace of G. You create a class </span>
<span class="cm">	 * in the given namespace, with given name and several base classes. </span>
<span class="cm">	 * The following example defined a class G.Father as base class and a </span>
<span class="cm">	 * class G.Child inherited from G.Father in the name space of Utils</span>
<span class="cm">	 * &lt;p&gt; &lt;code&gt;</span>
<span class="cm">	 *	Father = G.GClass(&#39;Utils&#39;, &#39;Father&#39;);&lt;br/&gt;</span>
<span class="cm">	 *	Father.prototype.__init = function(id) {&lt;br/&gt;</span>
<span class="cm">	 *		this.id = id;&lt;br/&gt;</span>
<span class="cm">	 *	}&lt;br/&gt;</span>
<span class="cm">	 * &lt;br/&gt;</span>
<span class="cm">	 *	Child = G.GClass(&#39;Utils&#39;, &#39;Child&#39;, G.Utils.Father);&lt;br/&gt;</span>
<span class="cm">	 *	Child.prototype.__init = function(id, name) {&lt;br/&gt;</span>
<span class="cm">	 *		this.__Utils__Father__init(id);&lt;br/&gt;</span>
<span class="cm">	 *		this.name = name;&lt;br/&gt;</span>
<span class="cm">	 *	}&lt;br/&gt;</span>
<span class="cm">	 * &lt;/code&gt;&lt;/p&gt;</span>
<span class="cm">	 * @static</span>
<span class="cm">	 * @method GClass</span>
<span class="cm">	 * @return {function}</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">namespace</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
		<span class="kd">var</span> <span class="nx">C</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">__init</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">arguments</span><span class="p">);</span>
		<span class="p">}</span>

		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">base</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){};</span>
			<span class="nx">base</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="nx">arguments</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prototype</span><span class="p">;</span>

			<span class="nx">C</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">base</span><span class="p">();</span>

			<span class="kd">var</span> <span class="nx">baseinit</span> <span class="o">=</span> <span class="s2">&quot;__&quot;</span> <span class="o">+</span> <span class="nx">C</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__className</span> <span class="o">+</span> <span class="s2">&quot;__init&quot;</span><span class="p">;</span>
			<span class="nx">C</span><span class="p">.</span><span class="nx">prototype</span><span class="p">[</span><span class="nx">baseinit</span><span class="p">]</span> <span class="o">=</span> <span class="nx">C</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="nx">C</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__className</span> <span class="o">=</span> <span class="nx">namespace</span> <span class="o">+</span> <span class="s2">&quot;__&quot;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">;</span>

		<span class="nx">G</span><span class="p">[</span><span class="nx">namespace</span><span class="p">]</span> <span class="o">=</span> <span class="nx">G</span><span class="p">[</span><span class="nx">namespace</span><span class="p">]</span> <span class="o">||</span> <span class="p">{};</span>
		<span class="nx">G</span><span class="p">[</span><span class="nx">namespace</span><span class="p">][</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">C</span><span class="p">;</span>
		<span class="k">return</span> <span class="nx">C</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * An interface for general G object that can fire events and </span>
<span class="cm">	 * bind event handler. </span>
<span class="cm">	 *</span>
<span class="cm">	 * @class EventListener</span>
<span class="cm">	 *</span>
<span class="cm">	 */</span>
	<span class="nx">EventListener</span> <span class="o">=</span> <span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span><span class="p">(</span><span class="s1">&#39;Base&#39;</span><span class="p">,</span> <span class="s1">&#39;EventListener&#39;</span><span class="p">);</span>
	<span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span> <span class="o">=</span> <span class="p">[];</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * &lt;P&gt;Bind an Object and it&#39;s function to a event handler. The event handler is</span>
<span class="cm">	 * the combination of an Object and an function.&lt;/P&gt;</span>
<span class="cm">	 * &lt;P&gt;An EventListener maintain a list of event handlers for every different </span>
<span class="cm">	 * event. If the event was binded to a handler at the first time, listen will</span>
<span class="cm">	 * be called. If the last event handler was unbinded, the unlisten will be called</span>
<span class="cm">	 * &lt;/P&gt;</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method bind</span>
<span class="cm">	 * @param evname {string} the name of the event</span>
<span class="cm">	 * @param func {function} which function will be called when the event occur.</span>
<span class="cm">	 * @param obj {object} what is the &quot;this&quot; point to in func.</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">bind</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="nx">func</span><span class="p">,</span> <span class="nx">obj</span><span class="p">)</span> 
	<span class="p">{</span>

		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;undefined&quot;</span> <span class="o">||</span> <span class="o">!</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="kd">var</span> <span class="nx">hdlList</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">dat</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;func&#39;</span><span class="o">:</span> <span class="nx">func</span><span class="p">,</span> <span class="s1">&#39;obj&#39;</span><span class="o">:</span> <span class="nx">obj</span><span class="p">};</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">hdlList</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">[</span><span class="nx">evname</span><span class="p">];</span>
			<span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">hdlList</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="nx">dat</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">dat1</span><span class="p">,</span> <span class="nx">dat2</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">return</span><span class="p">(</span><span class="nx">dat1</span><span class="p">.</span><span class="nx">obj</span> <span class="o">==</span> <span class="nx">dat2</span><span class="p">.</span><span class="nx">obj</span> <span class="o">&amp;&amp;</span> <span class="nx">dat1</span><span class="p">.</span><span class="nx">func</span> <span class="o">==</span> <span class="nx">dat2</span><span class="p">.</span><span class="nx">func</span><span class="p">);</span>
			<span class="p">});</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">n</span><span class="p">)</span>	<span class="k">return</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="nx">hdlList</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Utils</span><span class="p">.</span><span class="nx">List</span><span class="p">();</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">[</span><span class="nx">evname</span><span class="p">]</span> <span class="o">=</span> <span class="nx">hdlList</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Utils</span><span class="p">.</span><span class="nx">ListNode</span><span class="p">(</span><span class="nx">dat</span><span class="p">);</span>
		<span class="nx">hdlList</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">hdlList</span><span class="p">.</span><span class="nx">has_only_one</span><span class="p">())</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">__listen</span><span class="p">(</span><span class="nx">evname</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Unbind an event handler for the event with given name. If all the </span>
<span class="cm">	 * handler for this event was removed, the unlisten(evname) will be called.</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method unbind</span>
<span class="cm">	 * @param evname {string} name of the event</span>
<span class="cm">	 * @param func {function} function of the event handler</span>
<span class="cm">	 * @param obj {object} object of the event handler</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">unbind</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="nx">func</span><span class="p">,</span> <span class="nx">obj</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">dat</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;func&#39;</span><span class="o">:</span> <span class="nx">func</span><span class="p">,</span> <span class="s1">&#39;obj&#39;</span><span class="o">:</span> <span class="nx">obj</span><span class="p">};</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">hdlList</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">[</span><span class="nx">evname</span><span class="p">];</span>
			<span class="nx">n</span> <span class="o">=</span> <span class="nx">hdlList</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="nx">dat</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">dat1</span><span class="p">,</span> <span class="nx">dat2</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">return</span><span class="p">(</span><span class="nx">dat1</span><span class="p">.</span><span class="nx">obj</span> <span class="o">==</span> <span class="nx">dat2</span><span class="p">.</span><span class="nx">obj</span> <span class="o">&amp;&amp;</span> <span class="nx">dat1</span><span class="p">.</span><span class="nx">func</span> <span class="o">==</span> <span class="nx">dat2</span><span class="p">.</span><span class="nx">func</span><span class="p">);</span>
			<span class="p">});</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">n</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">hdlList</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>
			<span class="p">}</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">hdlList</span><span class="p">.</span><span class="nx">is_empty</span><span class="p">())</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">__unlisten</span><span class="p">(</span><span class="nx">evname</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * A class inherited form G.Base.EventListener should override this </span>
<span class="cm">	 * If something need to do before start monitor on some events.</span>
<span class="cm">	 * @method __listen</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__listen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * A class inherited form G.Base.EventListener should override this </span>
<span class="cm">	 * If something need to do before stop monitor on some events.</span>
<span class="cm">	 * @method __unlisten</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__unlisten</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Fire a event, and call all the handlers binded to it.</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method fire</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">fire</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">hdlList</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">handlerList</span><span class="p">[</span><span class="nx">evname</span><span class="p">];</span>
			<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">hdlList</span><span class="p">.</span><span class="nx">head</span><span class="p">;</span> <span class="nx">n</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">;</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">n</span><span class="p">.</span><span class="nx">data</span><span class="p">.</span><span class="nx">func</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">n</span><span class="p">.</span><span class="nx">data</span><span class="p">.</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">ev</span><span class="p">);</span>
			<span class="p">}</span>
		<span class="p">}</span>
	<span class="p">}</span>
<span class="p">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class="selected"><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_svg.html" title="svg">svg</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_utils.html" title="utils">utils</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="DOM.Element.html" title="DOM.Element">DOM.Element</a></li>
                                <li class=""><a href="EventListener.html" title="EventListener">EventListener</a></li>
                                <li class=""><a href="G.html" title="G">G</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="board.js.html" title="board.js">board.js</a></li>
                                <li class=""><a href="dom.js.html" title="dom.js">dom.js</a></li>
                                <li class="selected"><a href="g.js.html" title="g.js">g.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "EventListener.html#method_bind", "access": "", "host": "EventListener", "type": "method", "name": "bind"}, {"url": "DOM.Element.html#method_disable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "disable_drag"}, {"url": "DOM.Element.html#method_enable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "enable_drag"}, {"url": "EventListener.html#method_fire", "access": "", "host": "EventListener", "type": "method", "name": "fire"}, {"url": "G.html#method_GClass", "access": "", "host": "G", "type": "method", "name": "GClass"}, {"url": "DOM.Element.html#method_get_mouse", "access": "", "host": "DOM.Element", "type": "method", "name": "get_mouse"}, {"url": "DOM.Element.html#method_get_offset_in_page", "access": "", "host": "DOM.Element", "type": "method", "name": "get_offset_in_page"}, {"url": "G.html#method_get_uuid", "access": "", "host": "G", "type": "method", "name": "get_uuid"}, {"url": "DOM.Element.html#method___init", "access": "", "host": "DOM.Element", "type": "method", "name": "__init"}, {"url": "EventListener.html#method___listen", "access": "", "host": "EventListener", "type": "method", "name": "__listen"}, {"url": "G.html#method_Namespace", "access": "", "host": "G", "type": "method", "name": "Namespace"}, {"url": "DOM.Element.html#method_reg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "reg_resize_check"}, {"url": "EventListener.html#method_unbind", "access": "", "host": "EventListener", "type": "method", "name": "unbind"}, {"url": "EventListener.html#method___unlisten", "access": "", "host": "EventListener", "type": "method", "name": "__unlisten"}, {"url": "DOM.Element.html#method_unreg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "unreg_resize_check"}];
</script>
</body>
</html>
